package com.jiot.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.jfinal.kit.Ret;
import com.jfinal.plugin.redis.Redis;
import com.jiot.common.constant.CacheConstant;
import com.jiot.exce.EnumError;

public class LoginInterceptor implements Interceptor {
    public void intercept(Invocation inv) {
    	
        Controller c = inv.getController();
        System.out.println("password:"+c.getHeader("password"));
        System.out.println("account:"+c.getHeader("account"));
        if(!Redis.use(CacheConstant.appUser).exists(c.getHeader("account"))){
        	c.renderJson(Ret.fail().set("msg",EnumError.USER_NOT_LOGIN.getCode()));
        	return;
        }
        
        
        //前
        inv.invoke();
        //后
        
    }

	

}
